package com.example.mapper;

import com.example.pojo.Emp;
import org.apache.ibatis.annotations.*;

import java.time.LocalDateTime;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Li_DaChiZi
 * Date: 2025/9/3
 * Time: 11:12
 */
@Mapper
public interface EmpMapper {
//    @Select("select count(*) from emp")
// 带条件的总记录数
    Long count(
            @Param("name") String name,
            @Param("gender") Short gender,
            @Param("begin") LocalDateTime begin,
            @Param("end") LocalDateTime end
    );

//    @Select("select * from emp limit #{start},#{pageSize}")
    List<Emp> page(Integer start, Integer pageSize, String name, Short gender, LocalDateTime begin, LocalDateTime end);


    void deleteByIds(List<Integer> ids);


    void insertEmp(Emp emp);

    @Select("select * from emp where id = #{id}")
    Emp findById(Integer id);


    void updateById(Emp emp);

    @Select("select * from emp where username = #{username} and password = #{password}")
    Emp login(Emp emp);

    @Delete("delete from emp where dept_id = #{id}")
    void deleteById(Integer id);
}
